package com.cse.index.search;

import java.io.File;
import java.io.IOException;
import java.util.Date;

import javax.sql.rowset.serial.SerialArray;

import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermDocs;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.FSDirectory;

import com.cse.config.PropertyConfiguration;
import com.sun.mail.handlers.image_gif;

public class SearchIndex {
	
	public static void main(String[] args){
		
		String INDEX_STORE_PATH = ".\\index\\";
		
		try {
			IndexSearcher searcher = new IndexSearcher(INDEX_STORE_PATH);
			Term t = new Term("content", "iphone");
			Query query = new TermQuery(t);
			Hits hits = searcher.search(query);
			for(int i = 0 ;i < hits.length();i++){
				System.out.println(hits.doc(i).getField("content").stringValue());
			}
		} catch (IOException e) {
			System.out.println(e);
		}
		
		
	}

}
